package hn.cch.mybatis.configuration;

import hn.cch.mybatis.interceptor.CustomInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import javax.sql.DataSource;

@MapperScan("hn.cch.mybatis.mapper")
@Configuration
public class MyBatisConfiguration {

    // /**
    //  * 配置自定义拦截器
    //  *
    //  * @return
    //  */
    // @Bean
    // public CustomInterceptor customInterceptor() {
    //     return new CustomInterceptor();
    // }
    //
    // @Bean
    // public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource) {
    //     SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    //     sqlSessionFactoryBean.setDataSource(dataSource);
    //     sqlSessionFactoryBean.addMapperLocations(new ClassPathResource("classpath:mapper/SchoolMapper.xml"));
    //     return sqlSessionFactoryBean;
    // }
    //
    // @Bean
    // public SqlSessionFactory sqlSessionFactory(SqlSessionFactoryBean sqlSessionFactoryBean) throws Exception {
    //     return sqlSessionFactoryBean.getObject();
    // }


}
